﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EvoAlgLib
{
    public class RouletteWheelSelector : Selector
    {
        public RouletteWheelSelector(double s)
            : base(s) { }

        public override List<Individual> select()
        {
            List<Individual> couple = new List<Individual>();
            for (int i = 0; i < 2; ++i)
            {
                double val = LibStatics.getRandomizer().NextDouble();
                foreach (double d in fitTable.Keys)
                {
                    if (d > val)
                    {
                        couple.Add(fitTable[d]);
                        break;
                    }
                }
            }
            return couple;
        }
    }
}
